/*
 *Copyright (c) 2024 Black Sesame Technologies
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
*/

# ifndef custom_Std_Types
# define custom_Std_Types
typedef unsigned char   uint8;
typedef unsigned int    uint32;
#define ISR(IsrName)       void IsrName(void)
#define BIT(x)  (1UL << (x))
#ifndef BIT31
    #define BIT31   ((uint32)0x80000000UL)
#else 
      #if (BIT31 != 0x80000000UL) 
             #error "BIT31 is defined outside MCAL and it is value is not 0x80000000UL". 
       #endif 
#endif 
#ifndef BIT0
    #define BIT0    ((uint32)0x00000001UL)
#else 
      #if (BIT0 != 0x00000001UL) 
             #error "BIT0 is defined outside MCAL and it is value is not 0x00000001UL". 
       #endif 
#endif

#if !defined(REG_READ32)
#define REG_READ32(address)               (*(volatile uint32*)(address))
#endif

#if !defined(REG_WRITE32)
#define REG_WRITE32(address, value)       ((*(volatile uint32*)(address))= (value))
#endif

#if !defined(REG_BIT_SET32)
#define REG_BIT_SET32(address, mask)      ((*(volatile uint32*)(address))|= (mask))
#endif

#if !defined(REG_BIT_CLEAR32)
#define REG_BIT_CLEAR32(address, mask)    ((*(volatile uint32*)(address))&= (~(mask)))
#endif
#define REG_BIT_GET32(address, mask)      ((*(volatile uint32*)(address))& (mask))

#endif /* custom_Std_Types */